package cn.itsource.pethome.org.controller;

import cn.itsource.pethome.Basic.util.AjaxResult;
import cn.itsource.pethome.Basic.util.PageList;
import cn.itsource.pethome.org.domain.Shop;
import cn.itsource.pethome.org.domain.Status;
import cn.itsource.pethome.org.service.IShopService;
import cn.itsource.pethome.org.service.IStatusQueryService;
import cn.itsource.pethome.org.service.IStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/status")
public class StatusController {
    @Autowired
    private IShopService shopService;
    @Autowired
    private IStatusService statusService;

    @PatchMapping("/loadShopMessage")
    public Map<String,Object> statusQuery(Long shop_id){
        return shopService.findById(shop_id);
    }
    @PostMapping("/adopt")
    public AjaxResult adopt(@RequestBody Status status){
        try {
            statusService.adopt(status);
            return new AjaxResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResult(false,"操作失败"+e.getMessage());
        }
    }
    @PutMapping("/reject")
    public AjaxResult reject(@RequestBody Shop shop){
        try {
            statusService.reject(shop);
            return new AjaxResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResult(false,"操作失败"+e.getMessage());
        }
    }

}
